package com_2;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class ClientTCP {//定义一个客户端
    public static void main(String[] args) throws IOException {//main方法入口并抛出异常
        Socket  sk=new Socket("192.168.29.59",10086);//创建客户端对象，并规定相应的IP地址和端口
        OutputStream os = sk.getOutputStream();//获取字节输出流对象
        os.write("你好吗".getBytes());//将字节输出
        InputStream is = sk.getInputStream();
        byte[] bytes=new byte [1024];
        int ten = is.read(bytes);
        System.out.println("反馈是："+new String(bytes,0,ten));
        sk.close();//关闭资源
    }
}
